from django.db import models


class Device(models.Model):
    """ 设备表 """
    dy_account = models.CharField(verbose_name="抖音账号", max_length=64)  # varchar
    phone_model = models.CharField(verbose_name="手机型号", max_length=64)
    did = models.CharField(verbose_name="设备ID", max_length=32)

    class Meta:
        verbose_name_plural = "设备表"

    def __str__(self):
        return f"{self.did}-{self.dy_account}"


class Task(models.Model):
    """ 任务表 """
    # device_id = models.IntegerField(verbose_name="设备ID")
    # device_id
    device = models.ForeignKey(verbose_name="关联设备", to="Device", on_delete=models.CASCADE)

    address = models.TextField(verbose_name="直播间地址",help_text="手机中分享获得指定直播间地址")  # Text
    text = models.TextField(verbose_name="评论内容", help_text="回车换行，程序会自动读取每行进行评论")
    loop_count = models.IntegerField(verbose_name="循环次数", default=1)  # int

    #  0      1     2
    # 待执行/正在执行/完成
    status = models.IntegerField(verbose_name="状态", default=0, choices=[(0, "待执行"), (1, "正在执行"), (2, "已完成"), ])

    class Meta:
        verbose_name_plural = "任务表"
